<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *订单管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$manage_op=array('confirm','cancel','agree','disagree');
if(in_array($_RQ['op'],$manage_op)){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择订单！','error');
	}
}
$return=array();
$tabs=array(
	array('op'=>'list','title'=>'订单总列表'),
	
);
$return['status']=array('0'=>'待支付','1'=>'已支付','2'=>'已取消');
if($_RQ['op']=='list'){
	$params=array('seed_id >'=>0);
	$params['uniacid']=$_SESSION['uniacid'];
	if(!empty($_RQ['name'])){
		$params['name like']='%'.trim($_RQ['name']).'%';
		$return['params']['name']=$_RQ['name'];
	}if(isset($_RQ['status'])){
		$params['status']=intval($_RQ['status']);
		$return['params']['status']=$_RQ['status'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_farmer_order',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){			
			$item['member']=cfc('core')->member_show($item['mid']);
			$seed=pdo_get('jy_farmer_seed',array('id'=>$item['seed_id'],'uniacid'=>$_SESSION['uniacid']));
			$item['seed_title']=$seed['title'];
			//$item['land_title']=pdo_getcolumn('jy_farmer_land',array('id'=>$land['land_id'],'uniacid'=>$_SESSION['uniacid']),'title');
			$item['member']=pdo_get('core_members',array('id'=>$item['mid']));
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'客户购买土地后，需购买相应的种子，客户前端选择要种植的土地，然后进入种植流程！','edit'=>false,'del_one'=>true,'delall'=>true,'list'=>array(
			array('name'=>'member','title'=>'用户信息','type'=>'member'),
			array('type'=>'img_string','title'=>'联系人/电话',
			'data'=>array(
				array('title'=>'','name'=>'username'),
				array('title'=>'','name'=>'mobile')
				)
			),
			array('name'=>'seed_title','title'=>'种子名称','type'=>'string'),
			//array('name'=>'land_title','title'=>'所属土地','type'=>'string'),
			array('name'=>'num','title'=>'种植面积','type'=>'unitstring','unit'=>'㎡'),
			array('name'=>'money','title'=>'金额','type'=>'string'),
			array('name'=>'createtime','title'=>'时间','type'=>'time'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
		)),
		'search'=>array(
			array('name'=>'name','width'=>15,'title'=>'用户昵称','type'=>'string'),
			array('name'=>'status','width'=>15,'title'=>'订单状态','type'=>'select','options'=>'status_select'),
		)
	);
	$return['status_select']=array('0'=>array('id'=>'0','title'=>'待支付'),'1'=>array('id'=>'1','title'=>'已支付'),'2'=>array('id'=>'2','title'=>'已取消'));
	$return['htmls']=$htmls;
	exi($return);
}
